# coding=utf-8
__author__ = 'liubin'

from sqlalchemy import Column, Integer, String
from project import db


class User(db.Model):
    """
    用户表
    """
    __tablename__ = 'user_tab'
    id = Column(Integer, primary_key=True)
    name = Column(String(50), unique=True, index=True, nullable=False)
    pwd = Column(String(128), nullable=False)

    def __init__(self, name=None, pwd=None):
        self.name = name
        self.pwd = pwd

    def is_authenticated(self):
        return True

    def is_active(self):
        return True

    def is_anonymous(self):
        return False

    def get_id(self):
        return unicode(self.id)

    def __unicode__(self):
        return self.name